package com.yingxue.lesson.controller;

import com.cloud.feign.controller.FeignHystrixService;
import com.cloud.feign.service.RoleFeignService;
import com.cloud.feign.service.UserFeignService;
import com.yingxue.lesson.entity.SysUser;
import com.yingxue.lesson.service.OpenFeignService;
import com.yingxue.lesson.utils.DataResult;
import com.yingxue.lesson.vo.req.LoginReqVO;
import com.yingxue.lesson.vo.req.RolePageReqVo;
import com.yingxue.lesson.vo.req.UserPageReqVO;
import com.yingxue.lesson.vo.resp.HomeRespVO;
import com.yingxue.lesson.vo.resp.LoginRespVO;
import com.yingxue.lesson.vo.resp.PageVO;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.TimeUnit;

/**
 * @author lai
 * @version 1.0
 * @date 2021/5/29 22:20
 * @description
 */
@RestController
@RequestMapping("/feign")
@Api(tags = "测试")
public class OpenFeignController {

    @Autowired
    private UserFeignService userFeignService;
    @Autowired
    private FeignHystrixService feignHystrixService;

    @PostMapping("/api/users")
    public DataResult test(@RequestBody UserPageReqVO vo){
        DataResult<PageVO<SysUser>> pageVODataResult = userFeignService.pageInfo(vo);
        return pageVODataResult;
    }

    @PostMapping("/user/login")
    public DataResult test1(@RequestBody LoginReqVO vo){
        DataResult<LoginRespVO> login = userFeignService.login(vo);
        return login;
    }


    @PostMapping("/api/roles")
    public DataResult test3(@RequestBody RolePageReqVo vo){
        DataResult result = feignHystrixService.hystrixRole(vo);
        return result;
    }



    @GetMapping("/api/home")
    public DataResult test2(HttpServletRequest request){
        DataResult<HomeRespVO> home = userFeignService.getHome(request);
        return home;
    }



}
